
<!doctype html>
<html lang="en">
<head>
<META HTTP-EQUIV="pragma" CONTENT="no-cache"> 
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"> 
<META HTTP-EQUIV="expires" CONTENT="0">
<meta charset="UTF-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>委托逐月</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"content="width=device-width, initial-scale=1, maximum-scale=1">
<script src="../../../js/angular.js"></script>
<link rel="stylesheet" href="../../../layui/css/layui.css" media="all">
<script type="text/javascript" src="../../../layui/lay/modules/layer.js"></script>
<script src="../../../layui/jquery-3.2.1.min.js" charset="utf-8"></script>
<script src="../../../layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="../../../dwwsyyt/dw/gjjhbj/fy.js"></script>
</head>
<style>
         .layui-form-label{
         	 text-align: left;
             width:130px;
             height:30px;

     }
</style>
</head>


<body>
	<fieldset class="layui-elem-field layui-field-title"
		style="margin-top: 20px;">
		<legend>委托逐月</legend> 
	</fieldset>

    <div ng-app="myApp" ng-controller="customersCtrl" align="center">
    	<div>
 			<loading>查询中请稍后</loading>
		<div class="layui-form-item">
			<div class="layui-inline" >
				<label class="layui-form-label">姓名:</label>
				<div class="layui-input-inline">
					<input type="text" ng-model="XM" autocomplete="off"
						class="layui-input" readonly="readonly">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">证件号码:</label>
				<div class="layui-input-inline">
					<input type="text" ng-model="ZJHM" autocomplete="off"
						class="layui-input" readonly="readonly">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">联系电话:</label>
				<div class="layui-input-inline" >
					<input type="text" ng-model="DH" autocomplete="off"
						class="layui-input" >
				</div>
			</div>
		</div>
		<div class="layui-form-item">
		    <div class="layui-inline" >
				<label class="layui-form-label">个人账号:</label>
				<div class="layui-input-inline">
					<input type="text" ng-model="GRZH" autocomplete="off"
						class="layui-input" readonly="readonly">
				</div>
			</div>
			<div class="layui-inline" >
				<label class="layui-form-label">缴存银行:</label>
				<div class="layui-input-inline">
					<input type="text" ng-model="JCYH" autocomplete="off"
						class="layui-input" readonly="readonly">
				</div>
			</div>
			<div class="layui-inline" >
				<label class="layui-form-label">月缴存额:</label>
				<div class="layui-input-inline">
					<input type="text" ng-model="JCJE" autocomplete="off"
						class="layui-input" readonly="readonly">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline" >
				<label class="layui-form-label" >申请借款金额 :</label>
				<div class="layui-input-inline">
					<input type="text" ng-model="SQJKJE" autocomplete="off"
						class="layui-input" readonly="readonly">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label" >申请借款年限:</label>
				<div class="layui-input-inline">
					<input type="text" ng-model="SQJKQX" autocomplete="off"
						class="layui-input" readonly="readonly">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">缴存情况:</label>
				<div class="layui-input-inline">
					<input type="text" ng-model="JCQK" autocomplete="off"
						class="layui-input" readonly="readonly">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
		     <div class="layui-inline" >
				<label class="layui-form-label" >个人缴存余额:</label>
				<div class="layui-input-inline">
					<input type="text" ng-model="GRJCYE" autocomplete="off"
						class="layui-input" readonly="readonly">
				</div>
			</div>
			<div class="layui-inline" >
				<label class="layui-form-label">单位名称:</label>
				<div class="layui-input-inline">
					<input type="text" ng-model="DWMC" autocomplete="off"
						class="layui-input" readonly="readonly">
				</div>
			</div>
			<div class="layui-inline" >
				<label class="layui-form-label">单位代码:</label>
				<div class="layui-input-inline">
					<input type="text" ng-model="DWDM" autocomplete="off"
						class="layui-input" readonly="readonly">
				</div>
			</div>
		</div>
		<fieldset class="layui-elem-field layui-field-title"
			style="margin-top: 30px;"></fieldset>
		<div class="layui-form-item" style="">
		    <div class="layui-inline" >
				<label class="layui-form-label">还款人姓名:</label>
				<div class="layui-input-inline">
					<input type="text" ng-model="HKRXM" autocomplete="off"
						class="layui-input" readonly="readonly">
				</div>
			</div>
			<div class="layui-inline" >
				<label class="layui-form-label">月还款额:</label>
				<div class="layui-input-inline">
					<input type="text" ng-model="YHKE" autocomplete="off"
						class="layui-input" readonly="readonly">
		        </div>
		    </div>
		    <div class="layui-inline">
				<label class="layui-form-label">委托银行:</label>
				<div class="layui-input-inline">
					<input type="text" ng-model="WTYH" autocomplete="off"
						class="layui-input" readonly="readonly">
				</div>
	       	</div>
		  </div>
			<div class="layui-form-item">
				<div class="layui-inline" >
					<label class="layui-form-label" >还款起始日期:</label>
					<div class="layui-input-inline">
						<input type="text" ng-model="HKQSRQ" id="hqsrq"  autocomplete="off" readonly="readonly" class="layui-input">
					</div>
				</div>
			<div class="layui-inline" >
				<label class="layui-form-label">委托年限:</label>
				<div class="layui-input-inline">
				<select id="end" ng-model="selected" ng-change="change()" style="width:100%;height:35px;">
				<option ng-repeat="x in nums" value="{{x.num}}">{{x.year}}</option>
			   </select>
		        </div>
		    </div>
				<div class="layui-inline">
					<label class="layui-form-label" >还款中止日期:</label>
					<div class="layui-input-inline">
						<input type="text" ng-model="HKZZRQ" readonly="readonly" autocomplete="off"
							class="layui-input" id="zzrq">
					</div>
				</div>
			  </div>
		      <div class="layui-input-block">
					<button class="layui-btn"  ng-click="tj()">提交</button>
	          </div>
	   </div>
</div>
	<script>
		layui.use('element', function() {
			var $ = layui.jquery, element = layui.element;
		});
	</script>
	<script type="text/javascript" src="../../../layui/lay/modules/layer.js"></script>
	<script type="text/javascript" src="../../../layui/layer.ext.js"></script>
	<script type="text/javascript">
	  function getPath(){
		  return 'http://'+location.host;	
		      };
		var a;
			var app = angular.module('myApp', []);
			 app.directive('loading', function(){  
		        return {  
		            restrict: 'E',  
		            transclude: true,  
		            template: '<div ng-show="loading" class="loading" id="allDiv"  style="position:fixed; top:0px; left:0px; width:100%; height:100%; display:none; background-color:#000; opacity: 0.5; z-index:99999;">'  
		            +'<img alt="" src="../../../layui/layui/img/jz.gif" style="vertical-align: middle;width:30px; height:30px; position: absolute; top:50%; left:50%; margin-top: -50px; margin-left:-50px;"/>'
		            +'</div>',  
		            link: function (scope, element, attr) {  
		                scope.$watch('loading', function (val) {  
		                    if (val){  
		                        document.getElementById("allDiv").style.display = "block";  
		                    }else{  
		                        document.getElementById("allDiv").style.display = 'none';  
		                    }  
		                });  
		            }  
		        };
		    });  
			    app.controller('customersCtrl', function($scope, $http) {
			    $scope.setLoading =function(){  
				    if($scope.loading ==undefined || $scope.loading ==false){  
				        $scope.loading=true;  
				    }else{  
				        $scope.loading=false;  
				    };
				};	 
		        $scope.setLoading();
                  $scope.change=function(){
                      /* 获取时间控件选定的值 */
			          var qsrq=$("#hqsrq").val();
			          /* 获取点击的值 */
                      var djtonum=parseInt($scope.selected);
                      /* 取出年  月 日*/
                       var aa = new Date(qsrq);
                       
                       aa.setFullYear(aa.getFullYear()+djtonum);
                       var nian =aa.getFullYear();
                       var yue  =aa.getMonth()+1;
                       var new_date=new Date(nian,yue,1)
                       var new_date=new Date(new_date.getTime()-1000*60*60*24)
                       var tian =new_date.getDate();
                       if (yue >= 1 && yue <= 9) {
				            yue = "0" + yue;
				        }
				        if (tian >= 0 && tian <= 9) {
				            tian = "0" + tian;
				        }
                       var str=nian.toString()+"-"+yue.toString()+"-"+tian.toString();
                       /* 	
                       	//获取最;后一天
	                    var seperator1 = "-";  
	                    var date2=new Date(str);
	                    var new_month = date2.getMonth()+1;
	                    var new_year = date2.getFullYear();
	                    var new_date = new Date(new_year,new_month,1);
	                    var currentdate = new_year + seperator1 + new_month + seperator1 +(new Date(new_date.getTime()-1000*60*60*24)).getDate();  
                     	
                     	
                     	 //格式化日期    
                        var date1=new Date(currentdate);
                        var seperator2 = "-";
				        var year = date1.getFullYear();
				        var month = date1.getMonth() + 1;
				        var strDate = date1.getDate();
				        if (month >= 1 && month <= 9) {
				            month = "0" + month;
				        }
				        if (strDate >= 0 && strDate <= 9) {
				            strDate = "0" + strDate;
				        }
				       var currentdate = year + seperator2 + month + seperator2 + strDate;
				       alert(currentdate);
				       $("zzrq").innerhtml(str); */
                       $scope.HKZZRQ=str;
                  };
                  function getNextMonth(date) {
			            var arr = date.split('-');
			            var year = arr[0]; //获取当前日期的年份
			            var month = arr[1]; //获取当前日期的月份
			            var day = arr[2]; //获取当前日期的日
			            var days = new Date(year, month, 0);
			            days = days.getDate(); //获取当前日期中的月的天数
			            var year2 = year;
			            var month2 = parseInt(month) + 1;
			            if (month2 == 13) {
			                year2 = parseInt(year2) + 1;
			                month2 = 1;
			            }
			            var day2 = day;
			            var days2 = new Date(year2, month2, 0);
			            days2 = days2.getDate();
			            if (day2 > days2) {
			                day2 = days2;
			            }
			            if (month2 < 10) {
			                month2 = '0' + month2;
			            }
			        
			            var t2 = year2 + '-' + month2 + '-' + day2;
			            return t2;
			        }
			     $http({
					url : getPath() + "/wsyyt/wtzycontroller/test",
					contentType : "text/html;charset=utf-8",
					method : 'post',
				}).then(function(res) {
					$scope.setLoading();
				   if(res.data.msg==null){
								
								 	layer.msg("登陆失效请重新登陆");
									setTimeout(function () {
										window.top.location.href=res.data;
									}, 1500);
									return;
								 
					}else if(res.data.code==1){
				     //  layer.msg('提示：'+res.data.CW,{icon: 5});
				       layer.alert('提示：'+res.data.CW, {
								      skin: 'layui-layer-molv' //样式类名  自定义样式
								     ,closeBtn: 1    // 是否显示关闭按钮
								      ,anim: 1 //动画类型
								     ,btn: ['确认'] //按钮
								      ,icon: 5    // icon
								     ,btn2:function(){
										
						}});
				   }
				   function p(s) {
					    return s < 10 ? '0' + s: s;
					}
					
					var myDate = new Date();
					
					
					//获取当前年
					var year=myDate.getFullYear();
					//获取当前月
					var month=myDate.getMonth()+1;  
					var now=getNextMonth(year+"-"+month+"-"+"01");  //year+'-'+p(month+1)+"-"+"01";
				   $scope.XM=res.data.data[0].XINGMING;
				   $scope.HKRXM=res.data.data[0].XINGMING;
				   $scope.ZJHM=res.data.data[0].ZJHM;
				   $scope.DH=res.data.data[0].DH;
				   $scope.GRZH=res.data.data[0].GRZH;
				   $scope.JCYH=res.data.data[0].JCYH;
				   $scope.WTYH=res.data.data[0].WTYH;
				   $scope.JCJE=res.data.data[0].JCJE;
				   $scope.JCQK=res.data.data[0].JCQK;
				   $scope.DWDM=res.data.data[0].DWZH;
				   $scope.DWMC=res.data.data[0].DWMC;
				   $scope.DWMC=res.data.data[0].DWMC;
				   $scope.SQJKJE=res.data.data[0].SQJKJE;
				   $scope.SQJKQX=res.data.data[0].SQJKQX;
				   $scope.GRJCYE=res.data.data[0].YE;
				   $scope.YHKE=res.data.data[0].YHKE;
				   $scope.HKKH=res.data.data[0].XYHK;
				   $scope.HKQSRQ=now;
				   
				   var zhye=$scope.GRJCYE;
				 var yhje=$scope.YHKE;
				 var nx=Number(zhye)/Number(yhje);
				 if(nx>11.99 && nx<24){
				 	 $scope.nums = [
		                 {year : "1年", num : "1"},
	                 ];
				 }else if(nx>23.99 && nx<36 ){
				 	  $scope.nums = [
		                 {year : "1年", num : "1"},
		                 {year : "2年", num : "2"},
	                 ];
				 }else if(nx>35.99){
				 	  $scope.nums = [
		                 {year : "1年", num : "1"},
		                 {year : "2年", num : "2"},
		                 {year : "3年", num : "3"}
	                 ];
				 }else{
				 	layer.alert('提示：公积金账户余额不足一年贷款还款额,不能办理委托逐月提取!', {
								      skin: 'layui-layer-molv' //样式类名  自定义样式
								     ,closeBtn: 1    // 是否显示关闭按钮
								      ,anim: 1 //动画类型
								     ,btn: ['确认'] //按钮
								      ,icon: 5    // icon
								     ,yes:function(){
										window.parent.location.reload();
										parent.layer.close(index);
										
					}});
				 }
	      /** 提交申请function */
			$scope.tj = function() {
				if($scope.DH==null || $scope.DH == ''){
					//layer.msg('提示：请填写联系电话.....',{icon: 5});
					layer.alert('提示：请填写联系电话！', {
								      skin: 'layui-layer-molv' //样式类名  自定义样式
								     ,closeBtn: 1    // 是否显示关闭按钮
								      ,anim: 1 //动画类型
								     ,btn: ['确认'] //按钮
								      ,icon: 5    // icon
								     ,btn2:function(){
										
					}});
					return;
				}else if($scope.selected==null || $scope.selected == ''){
					//layer.msg('提示：请填写联系电话.....',{icon: 5});
					layer.alert('提示：请填写委托年限！', {
								      skin: 'layui-layer-molv' //样式类名  自定义样式
								     ,closeBtn: 1    // 是否显示关闭按钮
								      ,anim: 1 //动画类型
								     ,btn: ['确认'] //按钮
								      ,icon: 5    // icon
								     ,btn2:function(){
										
					}});
					return;
				}else{
				layer.alert('提示：请确认是否办理委托逐月还贷！', {
								      skin: 'layui-layer-molv' //样式类名  自定义样式
								     ,closeBtn: 1    // 是否显示关闭按钮
								      ,anim: 1 //动画类型
								     ,btn: ['确认','取消'] //按钮
								      ,icon: 6    // icon
								     ,yes:function(){
									
										
					
				$scope.setLoading();
				$scope.params = {
				   xm:$scope.XM,
				   wtyh : $scope.WTYH,
				   hkqsrq:$scope.HKQSRQ,
				   hkzzrq:$scope.HKZZRQ,
				   gsdqdm:res.data.data[0].GSDQDM,
				   dqdm:res.data.data[0].DQDM,
				   dkzh:res.data.data[0].DKZH,
				   dwmc:res.data.data[0].DWMC,
				   dwzh:res.data.data[0].DWZH,
				   htbh:res.data.data[0].HTBH,
				   dh:$scope.DH,
				   zjhm:res.data.data[0].ZJHM,
				   WTYH:res.data.data[0].WTYH,
				   jcyh:res.data.data[0].JCYH,
				   yjce:res.data.data[0].JCJE,
				   grzh:res.data.data[0].GRZH,
				   ye:res.data.data[0].YE,
				   HKKH:res.data.data[0].XYKH,
				   YHKE:res.data.data[0].YHKE
				};
				$http({
					url : getPath() + "/wsyyt/wtzycontroller/test1",
					contentType : "text/html;charset=utf-8",
					method : 'post',
					params : $scope.params,
				}).then(function(res) {
				 $scope.setLoading();
				   $scope.code=res.data.code;
		           if(res.data.msg==null){
								
								 	layer.msg("登陆失效请重新登陆");
									setTimeout(function () {
										window.top.location.href=res.data;
									}, 1500);
									return;
								 
				   }else if($scope.code==0){
		   				//layer.msg('提示：申请成功,等待审核.....',{icon: 6});
		   				layer.alert('提示：申请成功,等待审核.....', {
								      skin: 'layui-layer-molv' //样式类名  自定义样式
								     ,closeBtn: 1    // 是否显示关闭按钮
								      ,anim: 1 //动画类型
								     ,btn: ['确认'] //按钮
								      ,icon: 6    // icon
								     ,yes:function(){
										window.parent.location.reload();
										parent.layer.close(index);
										
					}});
					}else{
		  				//layer.msg('提示：'+res.data.CW,{icon: 5});
		  				layer.alert('提示：'+res.data.CW, {
								      skin: 'layui-layer-molv' //样式类名  自定义样式
								     ,closeBtn: 1    // 是否显示关闭按钮
								      ,anim: 1 //动画类型
								     ,btn: ['确认'] //按钮
								      ,icon: 5    // icon
								     ,yes:function(){
										window.location.href=window.location.href;
										
						}});
					}
				});
				}});
				}
			  };
			  /**重置function  */
			  $scope.cz=function(){
			    $scope.WTYH="";
				$scope.HKQSRQ="";
				$scope.HKZZRQ="";
			  };
			});
		});
	</script>
	<script type="text/javascript">
		function p(s) {
		    return s < 10 ? '0' + s: s;
		}
		
		var myDate = new Date();
		//获取当前年
		var year=myDate.getFullYear();
		//获取当前月
		var month=myDate.getMonth()+1;
		//获取当前日
		var date=myDate.getDate(); 
		var h=myDate.getHours();       //获取当前小时数(0-23)
		var m=myDate.getMinutes();     //获取当前分钟数(0-59)
		var s=myDate.getSeconds();  
		var now=year+'-'+p(month+1)+"-"+"01";
		$("#qsrq").html(now);
	</script>

</body>
</html>